{$extend "tmpl.master.html" $} {$/ NOTE: this template (and tmpl.master.html that it inherits from) intentionally mixes long-form and short-form tags purely for illustration purposes. you should probably pick one style or the other for your templates. :) /$} {$: "#content" | userdetails = $.full_name ? "#userdetails" : "#nouser" }

grips Template Engine

This is how a grips Template works.

{$% Here's how to put in some completely raw $} {$/ unparsed /$} content! %$}


{$= @userdetails $} {$} {$: "#userdetails" | info = $.info ? "#info" | mylinks = $.links.length ? "#links" : "#nolinks" }
{$= @"#controls" $}

User Details

{$let full_name = $.full_name }

Welcome back, {$=~h full_name $}!

{$} {$= @info $}

Your Links

{$= @mylinks $} Here's how to display some {$~h}html content{$}
{$} {$: "#controls" | which_controls = $.full_name ? "#logout" : "tmpl.other.html#login" }

{$= @which_controls $}

{$} {$: "#info" }

Random Info

{$= $.info $}

{$} {$: "#logout" } Logout {$} {$: "#links" | fave[-1..6] = $.favenum ? "*" | partychoice["yes","no","maybe"] = $.mychoice ? "X" : " " } Some numbers (* is my favorite): {$loop fave }{$= _.value $}{$= _.key $} {$} Will I be going to the party: {$* partychoice } {$= _.value $} {$= _.key $} {$} {$} {$: "#listitem" | evenodd = $.even ? "even" : "odd" | first = $.first ? "first" | last = $.last ? "last" } {$} {$: "#nouser" } {$= @"#controls" $} {$} {$: "#nolinks" }

-no links yet-

{$} {$: "#footer" } {$} {$: "#styles" } {$= @"tmpl.master.html#styles" $} {$}